iT邦幫忙

2026 iThome 鐵人賽

DAY 1
3
Software Development

快樂演算法系列 第 1

LSTM :'( YOLOE:)& 過度緩慢記憶+連滾帶爬發文 841

  • 分享至 

  • xImage
  •  

https://ithelp.ithome.com.tw/upload/images/20260820/201779446a5o9W7KKG.jpg

https://ithelp.ithome.com.tw/upload/images/20260820/20177944a1qwAQWsWr.jpg

https://ithelp.ithome.com.tw/upload/images/20260820/20177944stZNYDgn2a.jpg

https://ithelp.ithome.com.tw/upload/images/20260820/201779441PrbAv8BDs.jpg

https://ithelp.ithome.com.tw/upload/images/20260820/20177944F81acFCEmf.jpg

https://ithelp.ithome.com.tw/upload/images/20260820/201779442Q1xwTAWLv.jpg

https://ithelp.ithome.com.tw/upload/images/20260820/20177944jo3y4lz5CN.jpg

https://ithelp.ithome.com.tw/upload/images/20260820/20177944Uu7uCnj7pY.jpg

https://ithelp.ithome.com.tw/upload/images/20260820/20177944LWKO3ki2bY.jpg

https://ithelp.ithome.com.tw/upload/images/20260820/20177944VeJhCiHXdg.jpg

class Solution {//V+E V
public:
    bool canVisitAllRooms(vector<vector<int>>& room) {
        int countRoom = room.size();
        int remainingRoom = countRoom - 1 ;

        vector<char> canEnter(countRoom, 0);
        vector<int> roomToOpen;

        canEnter[0] = 1;
        roomToOpen.push_back(0);

        while (!roomToOpen.empty()) {
            int currentRoom = roomToOpen.back();

            roomToOpen.pop_back();
            for (int nextRoom : room[currentRoom]){
                if (!canEnter[nextRoom]) {
                    canEnter[nextRoom] = 1;
                    --remainingRoom;

                    if ( remainingRoom == 0)
                    return true;

                    roomToOpen.push_back(nextRoom);
                    }
                }
            }
        return remainingRoom == 0;
    }
};

下一篇
Auto training & gpt 今天好怪 &417初版 明日再繼續
系列文
快樂演算法2
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 則留言

0
RayYuanLiu
iT邦新手 5 級 ‧ 2026-08-20 21:44:31

太讚了吧!

0
饅頭
iT邦新手 5 級 ‧ 2026-08-21 15:10:46

手寫筆記真的好猛!

我要留言

立即登入留言